<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>


<script type="text/javascript" src="js/jquery.itextclear.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea', '.form').iTextClear();
    });
</script>
<!-- jQplot CSS -->

<link rel="stylesheet" media="screen" href="css/Tree.css"/>
<!-- jQplot CSS END -->

<!-- DATATABLES CSS -->
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>
<script type="text/javascript" src="lib/datatables/js/jquery.dataTables.js"></script>
<!-- DATATABLES CSS END -->

<script>
    $(document).ready(function() {
        $('#simple-button').popover('#simple-popover', {});
        $('#top-button').popover('#top-popover', {preventLeft: true, preventRight: true, preventBottom:true});
    });
</script>

<h1 class="page-title">审核组织架构</h1>

<div id="demo" class="clearfix">
    <table class="display" id="example">
        <thead>
        <tr>
            <th>选择</th>
            <th>审核对象</th>
            <th>审核层级</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <s:iterator value="#request.auditConfigs" var="config" status="sta">
            <s:if test="#sta.even"> <tr class="gradeA"> </s:if><s:else><tr class="gradeC"></s:else>
            <td><input type="checkbox" id="form-updates" value="1"/></td>
            <td>${config.auditType.name}</td>
            <td id="count_${config.auditType}">${config.count}</td>
            <td align="center">
                <s:if test="#request.config.count > 0">
                <a class="button" href="#authority/audit_config_detail.xhtml?auditType=${config.auditType}&organizationId=${organizationId}"><span style="background:url(${ctx}/images/img/zoom.png)" class="icon">&nbsp;</span>查看</a>
                </s:if>
                <a class="button" href="#authority/audit_config_set.xhtml?auditType=${config.auditType}&organizationId=${organizationId}"><span style="background:url(${ctx}/images/img/page_edit.png)" class="icon">&nbsp;</span>配置</a>
                <s:if test="#request.config.count > 0">
                <a class="button" onclick="resetConfig(this, '${config.auditType}')"><span style="background:url(${ctx}/images/img/cancel.png)" class="icon">&nbsp;</span>重置</a>
                </s:if>
            </td>
        </tr>
        </s:iterator>
        </tbody>
    </table>
</div>

<div class="clear"></div>

<script type="text/javascript" src="js/Tree.js"></script>
<script type="text/javascript">
    var currentTabOrgId = ${organizationId};
    var currentSelOrgId = ${organizationId};
    function loadListContent(url, topId) {
        var data = {"organizationId":topId};
        $.ajax(url, {
            type: "POST",
            data:{"organizationId":topId},
            dataType:"html",
            cache:false,
            success:function(a) {
                var obj = $("#list_content_" + topId);
                obj.html("");
                obj.append(a);
            },
            complete:function() {
            }
        });
    }

    //重置
    function resetConfig(obj, auditType){
        if(!confirm("确定要重置该审核环节吗?")){
            return;
        }
        $.getJSON("${ctx}/ajax/audit-config-reset.xhtml", {"auditing.auditingNo":auditType, "auditing.organization.id":${organizationId}}, function(res) {
            if(res){
                alert("重置成功");
                $("#count_"+auditType).text("0");
                $(obj).prev("a").prev("a").hide(); //隐藏查看按钮
                $(obj).hide(); //隐藏重置按钮
            }else{
                alert("重置失败,该审核配置可能在使用中");
            }
        });
    }
</script>

    
